package com.thinkingcoder.common.util;

import java.lang.reflect.Method;
import java.util.Arrays;

public interface MethodUtils {
    static boolean checkLocalMethod(final String method) {
        // 本地方法不代理
        if ("toString".equals(method) || "hashCode".equals(method) || "notifyAll".equals(method)
            || "equals".equals(method) || "wait".equals(method) || "getClass".equals(method)
            || "notify".equals(method)) {
            return true;
        }
        return false;
    }

    static boolean checkLocalMethod(final Method method) {
        return method.getDeclaringClass().equals(Object.class);
    }

    static String methodSign(Method method) {
        StringBuilder sb = new StringBuilder(method.getName());
        sb.append("@").append(method.getParameterCount());
        Arrays.stream(method.getParameterTypes()).forEach(c -> sb.append("_").append(c.getCanonicalName()));
        return sb.toString();
    }
}
